import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) { return originalPush.call(this, location, onResolve, onReject) }
  return originalPush.call(this, location).catch((err) => err)
}
const routes = [
  {
    path: '/',
    redirect: '/index'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/arce-login/arce-login.vue')
  },
  {
    path: '/index',
    name: 'index',
    redirect: '/dashboard',
    component: () => import('@/Layout/MainRouter/arce-Main.vue'),
    // 主页的四个子路由
    children: [
      // 主页模块
      {
        path: '/dashboard',
        name: 'dashboard',
        component: () => import('@/views/arce-index/arce-index.vue')
      },
      {
        path: '/agent',
        name: 'agent',
        component: () => import('@/views/arce-agent/arce-index.vue')
      },
      {
        path: '/classify',
        name: 'classify',
        component: () => import('@/views/arce-classify/arce-index.vue')
      },
      {
        path: '/aboutUs',
        name: 'aboutUs',
        component: () => import('@/views/acre-aboutUs/arce-index.vue')
      },
      {
        path: '/details',
        name: 'details',
        component: () => import('@/views/arce-details/arce-index.vue')
      },
      // 地产列表
      {
        path: '/arceList',
        name: 'arceList',
        component: () => import('@/views/arce-arceList/arce-index.vue')
      }
    ]
  },
  {
    path: '*',
    name: '404',
    component: () => import('@/views/404/arce-404.vue')

  }
]

const router = new VueRouter({
  routes
})

export default router
